<!-- application/layouts/scripts/layout.phtml -->
<?php 
/**
* File that sets the overall layout of the site.
* @package busmap
*/
$userSession = new Zend_Session_Namespace('Auth');
echo $this->doctype();
$this->headScript()->appendFile('/scripts/main.js');
$this->headScript()->appendFile('/scripts/map.js');
$this->headScript()->appendFile('/scripts/jquery-1.6.2.js');
$this->headScript()->appendFile('/scripts/jquery-ui-1.8.15.custom.min.js');
$this->headScript()->appendFile('/scripts/jquery.mousewheel.min.js');
$this->headScript()->appendFile('/scripts/mapbox.js');
	
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bussikaart v0.1</title>
<?php echo $this->headLink()->appendStylesheet('/css/global.css') ?>
<?php echo $this->headLink()->appendStylesheet('/css/mapIcons.css') ?>
<?php echo $this->headScript(); ?>
</head>
<body>
<div id="header">
	<div id="login-button">
		<?php
			$loginText = ($userSession->id)?'Logi välja':'Logi sisse (admin)';
			$action = ($userSession->id)?'logout':'login';
		?>
		<a href="<?php echo $this->url(array('controller'=>'auth', 'action'=>$action),'default',true); ?>"><?php echo $loginText ?></a>
	</div>
	<?php if($userSession->level == 1){ ?>
		<div id="administrator-menu">Administratsioon<br>
		<?php

			$adminMenuLinks = $this->navigation()->getContainer()->findBy('label','Administratsioon')->getPages();
			$pageInfo = $this->navigation()->findActive($this->navigation()->getContainer());
			foreach($adminMenuLinks as $adminMenuLink){
			
				$adminMenuLink->class = ($pageInfo && $pageInfo['page'] == $adminMenuLink)?'active':'default';
				$href = $this->url(
					array(
						'controller'=>$adminMenuLink->controller,
						'action'=>$adminMenuLink->action
					), 'default', true);
				$class = $adminMenuLink->class;
		?>
				<a href="<?php echo $href ?>" class="<?php echo $class ?>">
					<?php echo $adminMenuLink->label?>
				</a>
		<?php
		}

		?>

		</div>
	<?php }	?>
	<div id="header-logo">
	    <div><a href="/" id="logo_link">Bussikaart v0.1</a></div>
	</div>
	<div style="clear:both;"></div>
</div>
<div id="header-navigation">

	<?php
	
	$menuLinks = $this->navigation()->getContainer()->findBy('label','Bussikaart')->getPages();
	$pageInfo = $this->navigation()->findActive($this->navigation()->getContainer());
	foreach($menuLinks as $menuLink){
		$menuLink->class = ($pageInfo && $pageInfo['page'] == $menuLink)?'active':'default';
		$href = $this->url(array('controller'=>$menuLink->controller),'default',true);
		$class = $menuLink->class;
	?>
		<a href="<?php echo $href ?>" class="<?php echo $class ?>">
			<?php echo $menuLink->label?>
		</a>
	<?php
	}
	?>
	<div style="clear:both;"></div>

</div>
<?php
	echo '<div class="breadcrumbs">';
	echo $this->navigation()->breadcrumbs()->setLinkLast(true)->setMinDepth(0)->render();
	echo '</div>';
?>
<div id="content">
	<?php echo $this->layout()->content ?>
</div>
<div id="footer">
	<img src="http://framework.zend.com/images/PoweredBy_ZF_4LightBG.png" />
</div>


</body>
</html>